package lk.week02;

import commons.ListNode;

/**
 * ClassName: P0083_RemoveRepeatNode
 * Description:
 * Author: xyf
 * Date: 5/20/23 11:15 PM
 * Version: 1.0
 **/
public class P0083_RemoveRepeatNode
{
    public ListNode deleteDuplicates(ListNode head)
    {
        if (head == null)
        {
            return null;
        }
        ListNode dummyHead = new ListNode(-9999999);
        dummyHead.next = head;
        ListNode cur = dummyHead;
        while (cur.next != null)
        {
            if (cur.next.val == cur.val)
            {
                cur.next = cur.next.next;
            }
            else
            {
                cur = cur.next;
            }
        }
        return dummyHead.next;
    }
}
